package com.meowcook.mapper;

import com.meowcook.pojo.po.Message;
import com.meowcook.pojo.po.Session;
import com.meowcook.pojo.vo.MessageVO;
import com.meowcook.pojo.vo.SessionVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.ArrayList;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28792
 * Date: 2025-11-19
 * Time: 11:07
 */
@Mapper(componentModel = "spring")
public interface SessionPojoMapper {

    SessionPojoMapper INSTANCE = Mappers.getMapper(SessionPojoMapper.class);


    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "avatarUrl", target = "avatarUrl"),
            @Mapping(source = "numMember", target = "numMember")
    })
    ArrayList<SessionVO> toVO(ArrayList<Session> sessions);


    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "content", target = "content"),
            @Mapping(source = "createTime", target = "createTime"),
            @Mapping(source = "speaker.id", target = "speaker.id"),
            @Mapping(source = "speaker.nickname", target = "speaker.nickname"),
            @Mapping(source = "speaker.avatarUrl", target = "speaker.avatarUrl"),
            @Mapping(source = "speaker.isAdmin", target = "speaker.isAdmin")
    })
    MessageVO toVO(Message message);
}
